import React, { useRef, useState } from 'react'
import { SearchBar, } from 'antd-mobile'
import { SearchBarRef } from 'antd-mobile/es/components/search-bar'
import { NavBar, Space, Toast } from 'antd-mobile'
import { CloseOutline, MoreOutline, SearchOutline } from 'antd-mobile-icons'
import IllnessData from '../../component/IllnessData'
import { useNavigate } from 'react-router'
import instance from '../../request/axios'
import Recommendation from '../../component/RecommendationData/Index'

function index() {
    const nav = useNavigate();
    const back = () => {
        nav(-1)
    }

    const [data,setData] = useState([]);
    
    const HandleSearch = (value:any) => {
        console.log(value);
        instance.get('/api/date?wd='+ value).then((res) => {
            console.log(res);
            setData(res.data.data);
        })

    }
    return (
        <div>
            <NavBar onBack={back}>搜索</NavBar>
            <SearchBar onSearch={HandleSearch} placeholder='搜索疾病 | 疫苗 | 检查 | 治疗' />

            <Recommendation Recommended={data}></Recommendation>
        </div>
    )
}

export default index